package com.webdesign.action;

import java.util.List;


import java.util.Map;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;
import com.webdesign.dao.mapper.TbUserMapper;
import com.webdesign.dto.DisplayDTO;
import com.webdesign.entity.TbUser;
import com.webdesign.service.ITbDisplyService;



@Controller("DisplayHomeworkAction")
@Scope("prototype")
public class DisplayHomeworkAction {
	
	@Autowired
	private TbUserMapper tbUserMapper;
	
	private ITbDisplyService iTbDisplyService;
	
	private List<DisplayDTO> dsplyhws;
	
	/*
	 * 查看展示作业，根据用户名判断是教师查看还是学生查看，分别跳转到各自的页面
	 */
	public String homeworkDisplay(){
		dsplyhws = iTbDisplyService.homeworkDisplay();
		Map<String, Object> session = ActionContext.getContext().getSession();
		String userid = null;
		userid = (String)session.get("userid");
		TbUser tbUser = tbUserMapper.selectByPrimaryKey(userid);
		if(tbUser == null){
			return "teacher";
		}else{
			return "student";
		}
	}
	
	
	public TbUserMapper getTbUserMapper() {
		return tbUserMapper;
	}


	public void setTbUserMapper(TbUserMapper tbUserMapper) {
		this.tbUserMapper = tbUserMapper;
	}


	public ITbDisplyService getiTbDisplyService() {
		return iTbDisplyService;
	}
	
	@Resource(name="TbDisplyService")
	public void setiTbDisplyService(ITbDisplyService iTbDisplyService) {
		this.iTbDisplyService = iTbDisplyService;
	}

	public List<DisplayDTO> getDsplyhws() {
		return dsplyhws;
	}

	public void setDsplyhws(List<DisplayDTO> dsplyhws) {
		this.dsplyhws = dsplyhws;
	}
	
	

}
